package com.ict.web.controller.yzq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ict.web.dto.ContractInformationAddDto;
import com.ict.web.dto.ContractInformationEditDto;
import com.ict.web.vo.ContractInformationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.enums.BusinessType;
import com.ict.web.domain.ContractInformation;
import com.ict.web.service.IContractInformationService;
import com.ict.common.utils.poi.ExcelUtil;
import com.ict.common.core.page.TableDataInfo;

/**
 * 合同信息--刘杰Controller
 *
 * @author ruoyi
 * @date 2022-03-01
 */
@Api(tags = "合同信息")
@RestController
@RequestMapping("/contract/information")
public class ContractInformationController extends BaseController
{
    @Autowired
    private IContractInformationService contractInformationService;

    /**
     * 查询合同信息--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:information:list')")
    @GetMapping("/list")
    @ApiOperation("查询合同信息")
    public TableDataInfo list(ContractInformation contractInformation)
    {
        startPage();
        List<ContractInformation> list = contractInformationService.selectContractInformationList(contractInformation);
        return getDataTable(list);
    }

    /**
     * 导出合同信息--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:information:export')")
    @Log(title = "合同信息--刘杰", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出合同信息")
    public void export(HttpServletResponse response, ContractInformation contractInformation)
    {
        List<ContractInformation> list = contractInformationService.selectContractInformationList(contractInformation);
        ExcelUtil<ContractInformation> util = new ExcelUtil<ContractInformation>(ContractInformation.class);
        util.exportExcel(response, list, "合同信息--刘杰数据");
    }

    /**
     * 获取合同信息--刘杰详细信息
     */
//    @PreAuthorize("@ss.hasPermi('web:information:query')")
    @GetMapping(value = "/{contractId}")
    @ApiOperation("获取合同信息")
    public ContractInformationVo getInfo(@PathVariable("contractId") Long contractId)
    {
        return contractInformationService.selectContractInformationByContractId(contractId);
    }

    /**
     * 新增合同信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:add')")
    @Log(title = "合同信息--刘杰", businessType = BusinessType.INSERT)
    @ApiOperation("新增合同信息")
    @PostMapping
    public Long add(@RequestBody ContractInformationAddDto dto)
    {
        return contractInformationService.insertContractInformation(dto);
    }

    /**
     * 修改合同信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:edit')")
    @Log(title = "合同信息--刘杰", businessType = BusinessType.UPDATE)
    @ApiOperation("修改合同信息")
    @PutMapping("/edit/{contractId}")
    public AjaxResult edit(@RequestBody ContractInformationEditDto dto, @PathVariable Long contractId)
    {
        return toAjax(contractInformationService.updateContractInformation(dto, contractId));
    }

    /**
     * 删除合同信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:remove')")
    @Log(title = "合同信息--刘杰", businessType = BusinessType.DELETE)
    @ApiOperation("删除合同信息")
	@DeleteMapping("/{contractId}")
    public AjaxResult remove(@PathVariable Long contractId)
    {
        return toAjax(contractInformationService.deleteContractInformationByContractId(contractId));
    }
}
